<?php
	defined('RUN') or die('No access');

	class CategoryController
	{
		public function view($cat_id = 0)
		{
			$data = Model::get('website')->getLayoutData();
			
			if ($cat_id == 0)
			{
				$data['posts'] = Model::get('post')->getLastest(5);
			}
			else
			{
				$data['posts'] = Model::get('post')->getByCategory($cat_id);
			}

			$category = Model::get('category')->getById($cat_id);
			$data['title'] = ($category ? $category['name_vi'] : 'Dich vu du lich');
			$data['description'] = ($category ? $category['description'] : Config::get('page_description'));
			$data['keywords'] = ($category ? $category['keywords'] : Config::get('page_keywords'));
			$data['content_file'] = 'post/list.tpl';
			View::load('layout.tpl', $data, $data['temp']);
		}
	}
